package com.jy.rhin.infra.repo.notfication.topic.query.dto;

import com.google.common.collect.Lists;
import com.jy.rhin.domain.notification.topic.entity.EnumFilterType;
import com.jy.rhin.sdk.dto.notification.resp.TopicDetailDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicQueryDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicQueryFilterDto;
import lombok.Data;

import java.util.Date;

/**
 * @author WeiQ
 * @date 2022/6/30 14:55
 * 主题详情：包含主题、预存查询及过滤条件信息
 */
@Data
public class TopicFullInfoDTO {

    public TopicDetailDto toTopicDetailDto() {
        TopicDetailDto detailDto = new TopicDetailDto();
        detailDto.setId(this.id);
        detailDto.setPublisherName(this.publisherName);
        detailDto.setPublisherCode(this.publisherCode);
        detailDto.setTopicName(this.topicName);
        detailDto.setTopicExp(this.topicExp);
        detailDto.setTopicDesc(this.topicDesc);
        detailDto.setCreateTime(this.createTime);
        return detailDto;
    }

    public TopicQueryDto toTopicQueryDto() {
        TopicQueryDto topicQueryDto = new TopicQueryDto();
        topicQueryDto.setQueryExp(this.queryExp);
        topicQueryDto.setQueryName(this.queryName);
        topicQueryDto.setId(this.queryId);
        return topicQueryDto;
    }

    public TopicQueryFilterDto toTopicQueryFilterDto() {
        TopicQueryFilterDto queryFilterDto = new TopicQueryFilterDto();
        queryFilterDto.setId(this.filterId);
        queryFilterDto.setFilterName(this.filterName);
        queryFilterDto.setFilterExp(this.filterExp);
        queryFilterDto.setTargetPath(this.targetPath);
        queryFilterDto.setSourcePath(this.soapPath);
        queryFilterDto.setTopicExp(this.topicExp);
        queryFilterDto.setQueryExp(this.queryExp);
        queryFilterDto.setFilterType(this.filterType);
        queryFilterDto.setDicList(Lists.newArrayList());
        queryFilterDto.setRangeFlag(EnumFilterType.valueOf(this.filterType) == EnumFilterType.TEXT ? Boolean.FALSE : Boolean.TRUE);
        queryFilterDto.setRangeCode(this.filterCode);
        queryFilterDto.setXmlPath(this.soapPath);
        queryFilterDto.setJsonPath(this.targetPath);

        return queryFilterDto;
    }

    private Long id;
    private Long queryId;
    private Long filterId;
    private String publisherName;
    private String publisherCode;
    private String topicName;
    private String topicExp;
    private String topicDesc;
    private Date createTime;
    private String queryName;
    private String queryExp;
    private String filterName;
    private String filterExp;
    private String soapPath;
    private String targetPath;
    private Boolean rangeFlag;
    private String rangeCode;
    private String filterType;
    private String filterCode;


}
